{% extends "xadmin/my_base.html" %}


{% block body%}
<div class="container" style="width:90%">
    <div class="row">
        <div class="col-sm-10">
            <a href='{% url "repository:reference_log" repository.id %}?reference_name={{current_reference}}'>
                <span class="glyphicon glyphicon-time">{{ commit_count }} Commits</span>
            </a>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-10">
            <select style="width:40%" onchange="reference_change(value)">
                {% for reference in references %}
                    {% if current_reference == reference.name %}
                        <option value="{{reference.name}}" selected="">{{reference.name}}</option>
                    {% else %}
                        <option value="{{reference.name}}">{{reference.name}}</option>
                    {% endif %}
                {% endfor %}
            </select>
            {{current_path|safe}}
        </div>
        <div class="col-sm-2">{{ last_commit}}</div>
    </div>
    <div class="">
        <table class="table table-hover">
            <thead>
                <th style="width:20%"></th>
                <th style="width:65%"></th>
                <th style="width:15%"></th>
            </thead>
            <tbody>
                {% for file in file_list%}
                    <tr>
                        {% if file.type == 'tree' %}
                            <td class="glyphicon glyphicon-folder-close">
                                <a href='{% url "repository:repository_main" repository.id %}?reference_name={{current_reference}}&file_path={{ file.path }}'>
                                    {{file.name}}
                                </a>
                            </td>
                        {% else %}
                            <td class="glyphicon glyphicon-file">
                                <a href='{% url "repository:repository_file_content" repository.id %}?revision={{current_reference}}&file_path={{file.path}}'>
                                    {{file.name}}
                                </a>
                            </td>
                        {% endif %}
                        <td>{{file.message}}</td>
                        <td>{{file.committed_date}}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}

{% block script %}
<script>
    function reference_change(value){
        window.location.href='{% url "repository:repository_main" repository.id %}?reference_name='+value;
    }
</script>
{% endblock %}